<template>
    <div style="padding: 10px 15px">
        <my-table :data="resultList">
            <el-table-column
                label="列入日期"
                width="180"
            >
                <template slot-scope="scope">
                    {{ happenTimeFun(scope.row.putDate)}}
                </template>
            </el-table-column>
            <el-table-column
                label="决定列入部门(作出决定机关)"
                prop="putDepartment"
            ></el-table-column>
            <el-table-column
                label="列入原因"
                prop="putReason"
            ></el-table-column>
            <el-table-column
                label="移除日期"
            >
                <template slot-scope="scope">
                    {{ scope.row.removeDate ? scope.row.removeDate: '无'}}
                </template>
            </el-table-column>
            <el-table-column
                label="决定移除部门"
            >
                <template slot-scope="scope">
                    {{ scope.row.removeDepartment ? scope.row.removeDepartment: '无' }}
                </template>
            </el-table-column>
            <el-table-column
                label="移除原因"
            >
                <template slot-scope="scope">
                    {{ scope.row.removeReason ? scope.row.removeReason: '无' }}
                </template>
            </el-table-column>
        </my-table>
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :page-sizes="[10, 15, 20]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next"
            style="text-align: right; margin-top: 1em"
            :total="total"
        >
        </el-pagination>
        <el-link v-if="isLink" type="info" :underline="false">*此数据来源于天眼查官方网站</el-link>
    </div>
</template>

<script>
export default {
    props: {
        companyName: {
            type: String,
            default: "",
        },
        projectId: {
            type: String,
            default: "",
        },
        navName: {
            type: String,
            default: "",
        },
    },
    data: () => ({
        resultList: [],
        pageNum: 1,
        pageSize: 10,
        total: null,
    }),
    computed: {
        isLink() {
            return this.resultList.length > 0 ? true : false 
        }
    },
    methods: {
        // 时间格式化
        happenTimeFun(num) { //时间戳数据处理
            let date = new Date(num);
            //时间戳为10位需*1000，时间戳为13位的话不需乘1000
            let y = date.getFullYear();
            let MM = date.getMonth() + 1;
            MM = MM < 10 ? ('0' + MM) : MM; //月补0
            let d = date.getDate();
            d = d < 10 ? ('0' + d) : d; //天补0
            let h = date.getHours();
            h = h < 10 ? ('0' + h) : h; //小时补0
            let m = date.getMinutes();
            m = m < 10 ? ('0' + m) : m; //分钟补0
            let s = date.getSeconds();
            s = s < 10 ? ('0' + s) : s; //秒补0
            return y + '-' + MM + '-' + d; //年月日
            //return y + '-' + MM + '-' + d + ' ' + h + ':' + m+ ':' + s; //年月日时分秒
        },
        handleSizeChange: function (pageSize) {
            this.pageSize = pageSize;
            this.getResultList();
        },
        handleCurrentChange: function (pageNum) {
            this.pageNum = pageNum;
            this.getResultList();
        },

        // 获取 四库一平台人员 列表
        getResultList: function () {
            var that = this;
            this.$ajax({
                type: "get",
                url: `${this.$store.state.api.searchUrl}/searchtianyan/yzwf`,
                data: {
                    corpName: this.companyName,
                    pageNum: this.pageNum,
                    pageSize: this.pageSize,
                    projectId: this.projectId,
                },
                callback: function (data, res) {
                    // loading.close();
                    if (data.result) {
                        that.resultList = data.result.items;
                        that.total = data.result.total;
                        that.$emit('pushValidNames',that.navName)
                    }
                },
            });
        },
    },
    mounted() {
        this.getResultList();
    },
};
</script>

<style scoped lang="scss">
.company-right table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    ::v-deep tr th {
        background: #f1f7fd;
        color: #236ac4;
        font-weight: 400;
        padding: 10px 0;
        text-align: center;
        border: 1px solid #a4bee3;
    }
    ::v-deep td {
        border: 1px solid #a4bee3;
        padding: 10px 0px;
        font-size: 14px;
    }
    ::v-deep #commonClass {
        background: #4396de;
        color: #fff;
        font-size: 16px;
        text-align: center;
        height: 40px;
        line-height: 40px;
    }
    ::v-deep td:nth-child(odd) {
        text-align: center;
    }
    ::v-deep td:nth-child(even) {
        text-align: center;
    }
}
.company_tabs {
    margin: 0 15px;
    background: #206bc6;
    margin-top: 10px;
    ::v-deep span {
        display: inline-block;
        text-align: center;
        height: 36px;
        line-height: 36px;
        color: #fff;
        padding: 0px 20px;
        background: #206bc6;
        font-size: 15px;
    }
    ::v-deep .active {
        text-decoration: none;
        background: #4396de;
        box-sizing: border-box;
        border-bottom: 2px solid #eea108;
    }
}
</style>
